#define _CRT_SECURE_NO_WARNINGS
typedef struct
{
    int* a;
    int head;
    int tail;
    int k;

} MyCircularQueue;


MyCircularQueue* myCircularQueueCreate(int k)
{
    MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    obj->a = (int*)malloc(sizeof(int) * (k + 1));
    obj->k = k;
    obj->tail = obj->head = 0;
    return obj;
}

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    return obj->tail == obj->head;

}

bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return (obj->tail + 1) % (obj->k + 1) == obj->head;

}
bool myCircularQueueEnQueue(MyCircularQueue* obj, int value)
{
    if (myCircularQueueIsFull(obj))

    {
        return false;
    }
    else {
        obj->a[obj->tail] = value;
        obj->tail++;
        obj->tail %= (obj->k + 1);
        return true;
    }

}

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj))
    {
        return false;
    }
    else {
        obj->head++;
        obj->head %= (obj->k + 1);
        return true;

    }


}



int myCircularQueueFront(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj))
    {
        return -1;
    }
    else {
        return obj->a[obj->head];
    }
}

int myCircularQueueRear(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj))
    {
        return -1;
    }
    else
    {
        return obj->a[(obj->tail + obj->k) % (obj->k + 1)];
    }

}


void myCircularQueueFree(MyCircularQueue* obj) {

}